﻿using System;

namespace OpenLS.Spreadsheet
{
    internal class PasteInfo
    {
        public RangeFunction Functions { get; private set; }
        public bool Cut { get; private set; }

        internal CellRelativeAddress GetOffset (CellRelativeAddress offset)
        {
            if (Transpose)
                return new CellRelativeAddress(offset.Column, offset.Row);
            return offset;
        }

        public PasteInfo(RangeFunction functions, bool transpose, bool cut)
        {
            this.Functions = functions;
            this.Transpose = transpose;
            Cut = cut;
        }

        internal bool Transpose { get; set; }

        public CellAddress GetAddress(CellAddress sourceAddress, CellAddress sourceTopLeft, CellAddress targetTopLeft)
        {
            var offset = sourceAddress - sourceTopLeft; 
            return targetTopLeft + GetOffset(offset);
        }
    }
}